
'''size = 0
def calculate_size(target):
    global size
    d_list = os.listdir(target)
    print(d_list)
    for f in d_list:
        f = os.path.join(target_dir.f)
        print(f,os.path.getsize(f))
        size = size + os.path.getsize(f)
    returen size
dir_size = calculate_size(r'./New folder')
print(dir_size)'''
import os
size = 0
def calculate_size(target_dir):
    global size
    d_list = os.listdir(target_dir)
    print(d_list)
    for f in d_list:
        f = os.path.join(target_dir, f)
        print(f)
        if os.path.isfile(f):
            size = size + os.path.getsize(f)
        if os.path.isdir(f):
            get_dir_size(f)
        return size
print(calculate_size(r'C:\M5N\pmcs'))
